/**
 * \file ina209.h
 * \brief INA209 driver
 * \author Radim Badsi <radim.badsi@polytech.univ-montp2.fr>
 * \date 24/07/2009
 */

#ifndef INA209_H
#define INA209_H

#include "smallsatos.h"

#define  INA209_WADDR		0x84 /*!< I2C input address of the first INA209 */
#define  INA209_RADDR		0x85 /*!< I2C output address of the first INA209 */
#define  I2C_FIL_CHAUFFANT	0x82 /*!< I2C address of the antenna deployment actuator */

/**
  * INA209 command codes
  */
typedef enum { 
	CONFIGURATION=0x00, STATUS_REG=0x01, SMBUS=0x02,
	SHUNT_VOLTAGE=0x03, BUS_VOLTAGE=0x04, POWER=0x05,
	CURRENT=0x06, SHUNT_VOLTAGE_MAX=0x07, SHUNT_VOLTAGE_MIN=0x08,
	BUS_VOLTAGE_MAX=0x09, BUS_VOLTAGE_MIN=0x0A, POWER_MAX=0x0B
} command_ina209_t;

/**
  * Structure of an INA209 request
  * Used to request data from an INA209
  */
typedef struct
{
	int index; /*!< Device # */
	command_ina209_t command; /*!< Command */
	INT16U value; /*!< Value (to be filled by the driver after a request) */
} ina209_query;

/**
  * Return a pointer to the INA209 incoming queue
  * @return pointer to the INA209 incoming queue
  */
OS_EVENT* get_ina209_query_mbox(void);

/**
  * Return a pointer to the INA209 outgoing queue
  * @return pointer to the INA209 outgoing queue
  */
OS_EVENT* get_ina209_response_mbox(void);

/**
  * INA209 driver (OS task)
  */
void ina209_driver(void* pdata);
 
#endif